<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
</head>
<body>

<script src="/layui/layui.js"></script>
<script type="text/html" class="demoTable" id="myDiv">
<!--    搜索角色编号：-->
<!--    <div class="layui-inline" >-->
<!--        <input class="layui-input" name="id" id="roleId" autocomplete="off">-->
<!--    </div>-->
<!--搜索：-->
<!--    <div class="layui-inline" >-->
<!--        <input class="layui-input" name="id" id="userName" autocomplete="off">-->
<!--    </div>-->
        <button class="layui-btn layui-btn-sm" lay-event="cashInventoryinsert"><i
                 class="layui-icon">&#xe654;</i>新增</button>
<!--        <button class="layui-btn layui-btn-sm" lay-event="deleteAll">批量删除</button>-->
    <div class="layui-inline" style="position: relative;left: 30px;">
        <label class="layui-form-label" style="width: 90px">业务日期</label>
    <div class="layui-input-inline">
        <input type="text" class="layui-input" id="cashDate" name="cashDate" placeholder="日期">
    </div>
    </div>
    <div class="layui-inline" style="position: relative;left: 30px;">
    <label class="layui-form-label" style="width: 90px">业务类型</label>
    <div class="layui-input-inline">
        <select name="businessType" id="businessType" class="layui-input">
            <option value="0">无</option>
            <option value="1">管理费</option>
            <option value="2">托管费</option>
            <option value="3">存款利息</option>
            <option value="4">申购赎回款</option>
        </select>
    </div>
    </div>
<div class="layui-inline layui-show-xs-block">
    <button class="layui-btn layui-btn-primary" lay-submit="search" lay-event="search" lay-filter="sreach"><i class="layui-icon">&#xe615;</i>搜索
    </button>
</div>
</script>
<script>
    layui.use(['table','laydate', 'layer'], function () {
        var $ = layui.$;
        var table = layui.table;
        var form = layui.form;
        var laydate=layui.laydate;
        var layer = layui.layer;
        table.render({
            elem: '#trackone'
            ,id:'testReload'
            ,totalRow: true
            ,page: true
            ,url:'cashInventorySelect'
            ,toolbar:'#myDiv'
            ,height:"full-20"
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,cols: [[
                 {field: 'cashAccruedId', title: '现金应收应付编号', align: 'center',hide:true}
                //,{field: 'cashId', title: '现金编号',hide:true}
                , {field: 'fundId', title: '基金代码', align: 'center',hide:true}
               // , {field: 'fundName', title: '基金名称', align: 'center',hide:true}
                ,{field: 'cashDate', title: '业务日期'}
                ,{field: 'bankAccount', title: '银行账号'}
                ,{field: 'accounName', title: '账户名称'}
                // ,{field: 'fundId', title: '基金编号'}
                // ,{field: 'cashId', title: '现金id'}
                ,{field: 'businessType', title: '业务类型',templet:function (item) {
                        if(item.businessType == 1){
                            return'管理费'
                        }else if(item.businessType == 2){
                            return'托管费'
                        }else if(item.businessType == 3){
                            return'存款利息'
                        }else if(item.businessType == 4){
                            return'申购赎回款'
                        }
                    }}
                ,{field: 'moneyFlow', title: '资金流向',templet:function (item){
                        if (item.moneyFlow == 1){
                            return'流入';
                        } else if(item.moneyFlow == -1){
                            return '流出';
                        }
                    }}
                ,{field: 'moneySun', title: '总金额'}
                // <option value="1">管理费</option>
                //     <option value="2">托管费</option>
                //     <option value="3">存款利息</option>
                //     <option value="4">申购赎回款</option>


                ,{fixed: 'right', title:'操作' ,align:'center', toolbar: '#barDemo'}
            ]]
        });
        table.on('toolbar(trackone)',function (obj) {
            var cashDate=$("#cashDate").val();
            var businessType=$("#businessType").val();
            if (obj.event=='search'){
                alert("dsd")
                table.reload('trackone',{
                    url:'cashInventorySelects'
                    ,where: {
                        'cashDate':cashDate,
                        'businessType':businessType,
                    }
                    ,page:{
                        curr:1
                    }
                });
                $("#cashDate").val(cashDate);
                $("#businessType").val(businessType);

            }else if (obj.event=='cashInventoryinsert'){
                var CashInventoryinsert=layer.open({
                    area:['1000px','550px'],
                    type: 1,
                    title: '添加用户信息',
                    closeBtn: 1,
                    move:false,
                    content:$("#add")
                });
            }
        });
        table.on('tool(trackone)',function (obj) {
            var data = obj.data;
            if (obj.event=='cashInventorydelete'){

                layer.confirm('您确定要删除吗', function (index) {
                    layer.close(index);
                    $.getJSON(
                        'cashInventorydelete'
                        ,'cashAccruedId='+data.cashAccruedId
                        ,function (msg) {
                            if(msg==1){
                                alert("删除成功");
                                table.reload('testReload')
                            }else {
                                alert("删除失败");
                                table.reload('testReload')
                            }
                        });
                })
            }else if (obj.event=='cashInventoryupdate'){
                var bookObj=$.parseJSON(JSON.stringify(data));
                form.val("upform",bookObj);
                var index=layer.open({
                    area:['1000px','550px'],
                    type: 1,
                    title: '修改用户信息',
                    closeBtn: 1,
                    move:false,
                    content:$("#up")
                });
            }
        })

        form.on('submit(addsubmit)',function () {
            // alert("新增表单提交");
            var formData= form.val("addform");
            $.get('cashInventoryinsert',formData,
                function(msg) {
                    table.reload('testReload')
                });
        });
        form.on('submit(upsubmit)',function () {
            alert("修改");
            var formData= form.val("upform");
            alert(formData);
            $.get(
                'cashInventoryupdate',
                formData,
                function(msg) {
                    table.reload('testReload')
                });
        });
        laydate.render({
            elem: '#dates',
            //解决窗口闪退
            trigger:'click',
        });
        laydate.render({
            elem: '#datess',
            //解决窗口闪退
            trigger:'click',
        });
        laydate.render({
            elem: '#cashDate',
            //解决窗口闪退
            trigger:'click',
        });
    });
    layui.use(['tableSelect'],function (){
        //加载用到layui组件
        var form = layui.form;
        var $=layui.$;
        var tableSelect = layui.tableSelect;
        //下拉表格 的渲染
        tableSelect.render({
            elem: '#accounNameId',//渲染表格 与 文本框绑定
            searchKey:'accounName',//后端根据这个名称得到下拉表格中文本框的值
            table: {
                url: 'pageCash',//数据接口
                cols: [[
                    {type: 'radio'},
                    {field:'accounName',title: '账户名称'}
                    ,{field:'bankAccount',title: '银行账号'}
                    ,{field:'bankName',title: '银行名称'}
                    ,{field:'cashId',title: '账号id', hidden: true}
                ]]
            },
            //回调函数
            done: function (elem, data) {
                var Name='';
                //遍历选中的数据
                $.each(data.data,function (index,item) {
                    Name=item.accounName;
                    $("#accounNameId").val(item.accounName);
                    $("#cashIds").val(item.cashId);
                });
                elem.val(Name);//给输入框里显示的值赋值
            }
        })
    })
    layui.use(['tableSelect'],function () {
        //加载用到layui组件
        var form = layui.form;
        var $=layui.$;
        var tableSelect = layui.tableSelect;
        //下拉表格 的渲染
        tableSelect.render({
            elem: '#bankAccountId',//渲染表格 与 文本框绑定
            searchKey:'cashId',//后端根据这个名称得到下拉表格中文本框的值
            table: {
                url: 'cashInventorySelect',//数据接口
                cols: [[
                    {type: 'radio'},
                    {field:'accounName',title: '账户名称'}
                    ,{field:'bankAccount',title: '银行账号'}
                    ,{field:'bankName',title: '银行名称'}
                    ,{field:'cashId',title: '账号id', hidden: true}
                ]]
            },
            //回调函数
            done: function (elem, data) {
                var Name='';
                //遍历选中的数据
                $.each(data.data,function (index,item) {
                    Name=item.cashId;
                    $("#bankAccountId").val(item.cashId);
                    $("#cashId").val(item.cashId);
                });
                elem.val(Name);//给输入框里显示的值赋值
            }
        })
    })

</script>
<table id="trackone" lay-filter="trackone"></table>

<div id="add" style="display: none; height: 100%; height: 100%; text-align: center;">
    <form id="addform" lay-filter="addform"
          class="layui-form layui-form-pane"
          style="margin: 30px auto; display: inline-block;width: 100%">
        <div style="Float: left; width: 40%; margin-left: 10%">
        <div class="layui-form-item" style="text-align: center;">
            <label class="layui-form-label">账户名称</label>
            <div class="layui-input-inline" >
                <input type="text" name="accounName" lay-verify="required" id="accounNameId"
                       autocomplete="off" placeholder="请输入账户名称" class="layui-input">
                <input type="hidden" id="cashIds" name="cashIds">

            </div>
        </div>
<!--        <div class="layui-form-item" style="text-align: center;">-->
<!--            <label class="layui-form-label">基金编号</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" name="fundId" lay-verify="required"-->
<!--                       autocomplete="off" placeholder="请输入基金编号" class="layui-input">-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-form-item" style="text-align: center;">-->
<!--            <label class="layui-form-label">现金id</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" name="cashId" lay-verify="required"-->
<!--                       autocomplete="off" placeholder="请输入现金id" class="layui-input">-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-form-item" style="text-align: center;">
            <label class="layui-form-label">业务日期</label>
            <div class="layui-input-inline">
                <input type="text" name="cashDate" class="layui-input" id="dates" placeholder="业务日期" >
            </div>
        </div>
        <div class="layui-form-item">
                <label class="layui-form-label">资金流向</label>
                <div class="layui-input-inline">
                    <!--                <input type="radio" name="moneyFlow" value="流入" title="流入">-->
                    <!--                <input type="radio" name="moneyFlow" value="流出" title="流出">-->
                    <select name="moneyFlow">
                        <option value="">请选择</option>
                        <option value="1">流入</option>
                        <option value="-1">流出</option>
                    </select>
                </div>
        </div>
        </div>
        <div style="Float: left; width: 40%; margin-left: 10%">

        <div class="layui-form-item">
                <label class="layui-form-label ">业务类型</label>
                <div class="layui-input-inline">
                    <!--                <input type="radio" name="businessType" value="1" title="1">-->
                    <!--                <input type="radio" name="businessType" value="0" title="2">-->
                    <select name="businessType">
                        <option value="0">请选择</option>
                        <option value="1">管理费</option>
                        <option value="2">托管费</option>
                        <option value="3">存款利息</option>
                        <option value="4">申购赎回款</option>
                    </select>
                </div>
        </div>
        <div class="layui-form-item" style="text-align: center;">
            <label class="layui-form-label">总金额</label>
            <div class="layui-input-inline">
                <input type="text" name="moneySun" lay-verify="required"
                       autocomplete="off" placeholder="请输入总金额" class="layui-input">
            </div>
        </div>


        </div>
<!--        <div class="layui-form-item" style="text-align: center;">-->
<!--            <label class="layui-form-label">业务状态</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" name="businessStatu" lay-verify="required"-->
<!--                       autocomplete="off" placeholder="请输入业务状态" class="layui-input">-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-form-item" style="text-align: center;">-->
<!--            <label class="layui-form-label">业务类型</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" name="businessType" lay-verify="required"-->
<!--                       autocomplete="off" placeholder="请输入业务类型" class="layui-input">-->
<!--            </div>-->
<!--        </div>-->


        <div style="position: absolute; bottom: 200px; left: 31.5%;">
            <button class="layui-btn" lay-submit="" lay-filter="addsubmit">
                <i class="layui-icon">&#x1005;</i>添加
            </button>
        </div>
        <div style="position: absolute; bottom: 200px; left: 60%;">
            <!--lay-submit="" 具备提交功能  lay-filter   具有筛选作用-->
            <button class="layui-btn layui-bg-red cancel" type="button">
                <i class="layui-icon">&#x1006;</i>取消
            </button>
        </div>
    </form>
</div>
<div id="up"
     style="display: none; height: 100%; height: 100%; text-align: center;">
    <form id="upform" lay-filter="upform"
          class="layui-form layui-form-pane"
          style="margin: 30px auto; display: inline-block;width: 100%">
        <div style="Float: left; width: 40%; margin-left: 10%">
            <div class="layui-form-item" style="text-align: center;">
                <label class="layui-form-label">账户编号</label>
                <div class="layui-input-inline" >
                    <input type="text" name="bankAccount" lay-verify="required" id="bankAccountId"
                           autocomplete="off" placeholder="请选择银行编号" class="layui-input">
                    <input type="hidden" id="cashId" name="cashId">
                    <input type="hidden" id="fundId" name="fundId">
                    <input type="hidden" id="cashAccruedId" name="cashAccruedId">
                </div>
            </div>
        <div class="layui-form-item" style="text-align: center;">
            <label class="layui-form-label">业务日期</label>
            <div class="layui-input-inline">
                <input type="text" name="cashDate" class="layui-input" id="datess" placeholder="业务日期" >
            </div>
        </div>
            <div class="layui-form-item">
                <label class="layui-form-label">资金流向</label>
                <div class="layui-input-inline">
                    <!--                <input type="radio" name="moneyFlow" value="流入" title="流入">-->
                    <!--                <input type="radio" name="moneyFlow" value="流出" title="流出">-->
                    <select name="moneyFlow">
                        <option value="">请选择</option>
                        <option value="1">流入</option>
                        <option value="-1">流出</option>
                    </select>
                </div>
            </div>
        </div>
        <div style="Float: left; width: 40%; margin-left: 10%">


        <div class="layui-form-item">
            <label class="layui-form-label">业务类型</label>
            <div class="layui-input-inline">
<!--                <input type="radio" name="businessType" value="1" title="1">-->
<!--                <input type="radio" name="businessType" value="0" title="2">-->
                <select name="businessType">
                    <option value="">请选择</option>
                    <option value="1">管理费</option>
                    <option value="2">托管费</option>
                    <option value="3">存款利息</option>
                    <option value="4">申购赎回款</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item" style="text-align: center;">
            <label class="layui-form-label">总金额</label>
            <div class="layui-input-inline">
                <input type="text" name="moneySun" lay-verify="required"
                       autocomplete="off" placeholder="请输入总金额" class="layui-input">
            </div>
        </div>

        </div>


        <div style="position: absolute; bottom: 200px; left: 31.5%;">
            <button class="layui-btn" lay-submit="" lay-filter="upsubmit">
                <i class="layui-icon">&#x1005;</i>修改
            </button>
        </div>
        <div style="position: absolute; bottom: 200px; left: 60%;">
            <!--lay-submit="" 具备提交功能  lay-filter   具有筛选作用-->
            <button class="layui-btn layui-bg-red cancel" type="button">
                <i class="layui-icon">&#x1006;</i>取消
            </button>
        </div>
    </form>
</div>
<div style="display: none;" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="cashInventoryupdate"><i
            class="layui-icon">&#xe642;</i>修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="cashInventorydelete"><i
            class="layui-icon">&#xe640;</i>删除</a>
</div>

</body>
</html>